package cn.itsource.intercepto;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private LoginInterceptor loginInterceptor;


    /**
     * 注册我自定义的拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") //拦截所有
                .excludePathPatterns("/login")//放行login登录 ，不拦截
                .excludePathPatterns("/minio") //上传图片
                .excludePathPatterns("/course/updown") //导入execl文件
                .excludePathPatterns("/swagger-resources/**") //下面4个都是swagger的放行
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/v2/**")
                .excludePathPatterns("/swagger-ui.html/**")
        ;
    }
}
